package ig.da.abs;

import ig.util.ejb.IGBean;
import java.sql.Connection;
import java.sql.SQLException;

public class DBConnection {

    /*Paginacion y filtros*/
    
    protected Connection connection = null;

    /**
     * invoke close in all component
     * @param obj
     */
    public void close(Object... obj) {
    	if(obj==null || obj.length==0){
            /*try {
                connection.close();connection=null;
            } catch (Exception e) {}*/
    	}
        for (int i = 0; i < obj.length; i++) {
            try {
                if(obj[i]!=null){
                    if( obj[i] instanceof java.sql.PreparedStatement){
                            ((java.sql.PreparedStatement)obj[i]).close();
                    }else if( obj[i] instanceof java.sql.Statement){
                            ((java.sql.Statement)obj[i]).close();
                    }else if( obj[i] instanceof java.sql.Connection){
                            //((java.sql.Connection)obj[i]).close();
                    }else if( obj[i] instanceof java.sql.ResultSet){
                            ((java.sql.ResultSet)obj[i]).close();
                    }
                //java.lang.reflect.Method method = obj.getClass().getMethod("close");
                //method.invoke(obj[i]);
                }
            } catch (Exception e) {
            }
        }
    }
    
}
